

#include "stdafx.h"
#include "pf_clipboard.h"
#include "pf_block.h"
#include "pf_layer.h"
#include "pf_entity.h"

PF_Clipboard* PF_Clipboard::uniqueInstance = NULL;



void PF_Clipboard::clear() {
	graphic.clear();
	graphic.clearBlocks();
	graphic.clearLayers();
	graphic.clearVariables();
}





void PF_Clipboard::addBlock(PF_Block* b) {
	if (b!=NULL) {
		graphic.addBlock(b, false);
	}
}


bool PF_Clipboard::hasBlock(const QString& name) {
	return (graphic.findBlock(name)!=NULL);
}


void PF_Clipboard::addLayer(PF_Layer* l) {
	if (l!=NULL) {
		//graphic.addLayer(l->clone());
		graphic.addLayer(l);
	}
}



bool PF_Clipboard::hasLayer(const QString& name) {
	return (graphic.findLayer(name)!=NULL);
}



void PF_Clipboard::addEntity(PF_Entity* e) {
	if (e!=NULL) {
		//graphic.addEntity(e->clone());
		graphic.addEntity(e);
		e->reparent(&graphic);
	}
}

/**
 * Dumps the clipboard contents to stdout.
 */
std::ostream& operator << (std::ostream& os, PF_Clipboard& cb) {
	os << "Clipboard: " << cb.graphic << "\n";

	return os;
}

